package dao

import "gorm.io/gorm"

func Pagination(page, limit int) func(db *gorm.DB) *gorm.DB {
	if page <= 0 || limit <= 0 {
		page = 1
		limit = 10
	}
	offset := (page - 1) * limit
	return func(db *gorm.DB) *gorm.DB {
		return db.Offset(offset).Limit(limit)
	}
}
